1 package controllers
.actions
;
3 import javax
.swing
.undo
.AbstractUndoableEdit
;
4 import models
.GraphVertex
;
7 public class Rename
extends AbstractUndoableEdit
{
8 private static final long serialVersionUID
= -7929100929760152271L;
10 private String savedName
;
11 private int originalWidth
;
12 private SelectionController selectionController
;
13 public Rename(String name
, SelectionController selectionController
)
15 this.selectionController
= selectionController
;
16 this.savedName
= name
;
17 this.o
= selectionController
.getSelectedVertex();
18 originalWidth
= o
.getWidth();
24 System
.out
.println("REDO - " + o
.getName() + " -> " + savedName
);
25 int width
= 20 + this.selectionController
.getPanel().getDrawTextWidth(savedName
);
26 if(width
> o
.getWidth())
29 String objectName
= o
.getName();
31 savedName
= objectName
;
36 String objectName
= o
.getName();
38 o
.setWidth(originalWidth
);
39 savedName
= objectName
;